import Instance from '@/utils/http.ts';
import {RouteParamValue} from "vue-router";

export function useGetAllMaterialAPI(current:number,pageSize:number){
    return Instance({
        url:'/material/getAllByPage',
        method:'GET',
        params: {current: current, pageSize: pageSize}
    })
}

export function useGetByTypeAPI(typeName: string, orderBy: Number, current: number, pageSize:number) {
    return Instance({
            url: '/material/getByTypeName',
            method: 'GET',
            params: {typeName, orderBy,current,pageSize}
        }
    )
}
export function useGetAllCountAPI() {
    return Instance({
            url: '/material/getAllMaterialTerms',
            method: 'GET',
        }
    )
}
export function useGetCountsByTypeNameAPI(typeName:string) {
    return Instance({
            url: '/material/getCountsByTypeName',
            method: 'GET',
            params:{
                typeName
            }
        }
    )
}

//  多功能查询接口
export function useGetByMultifunctionAPI(name:string,current:number,pageSize:number) {
    return Instance({
            url: '/material/getByMultifunction',
            method: 'GET',
            params:{
                name,current,pageSize
            }
        }
    )
}
// 配合多功能查询接口获取数据条数
export function useGetCountByMultifunctionNameAPI(name:string) {
    return Instance({
            url: '/material/getCountByMultifunctionName',
            method: 'GET',
            params:{
                name
            }
        }
    )
}

// 多文件下载
export function useDownloadFilesAPI(files:[]) {
    return Instance({
            url: '/material/downLoadFiles',
            method: 'POST',
            data:files,
            responseType:'blob',
        }
    )
}
// 修改材料的状态（报废、变卖）---要配合数据库
export function useModifyStatusAPI(formData:FormData) {
    return Instance({
            url: '/material/modifyMaterialStatus',
            method: 'PUT',
            headers: {
                'content-type': 'multipart/form-data'
            },
            data:formData
        }
    )
}

// 通过id删除一套数据
export function useDeleteOneByIdAPI(id:number) {
    return Instance({
            url: `/material/${id}`,
            method: 'DELETE',
        }
    )
}

// 通过id获取一条材料数据
export function useGetOneByIdAPI(id: string | RouteParamValue[]){
    return Instance({
        url:`/material/${id}`,
        method:'GET'
    })
}

// 修改一条材料信息
export function useModifyMaterialAPI(formData:FormData){
    return Instance({
        url:`/material/modifyOne`,
        method:'PUT',
        headers: {
            'content-type': 'multipart/form-data'
        },
        data:formData
    })
}

export function useModifyMaterialByStockTakeNumberAPI(material:{}){
    return Instance({
        url:`/material/modifyStockTakeNumber`,
        method:'PUt',
        data:material
    })
}

//不分页获取所有数据
export function useGetAllAPI(){
    return Instance({
        url:`/material/getAll`,
        method:'GET'
    })
}

// 确认盘点功能
export function useConfirmStockTakeAPI() {
    return Instance({
        url:`/material/modifyFinalStockTakeNumber`,
        method:'put',
    })
}


